from pyspark import SparkConf, SparkContext

import os
# 指定解释器路径
# os.environ['PYSPARK_PYTHON'] = 'D:/Develop/Lang/Python/Python311/python.exe'
# os.environ['PYSPARK_PYTHON'] = 'D:/Develop/lang/Python/Python312/python.exe'

# 创建SparkConf
conf = SparkConf().setMaster('local[*]').setAppName('test_spark_app')

sc = SparkContext(conf=conf)

rdd = sc.parallelize([1, 2, 3, 4, 5]).filter(lambda a: a % 2 != 0)

# reduceByKey
# [1, 3, 5]
print(rdd.collect())

# 停止spark
sc.stop()
